package SV_DOS_ARRINDEX;
import jakarta.servlet.http.*;
public class Vulnerable_02 {
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
            IOException {
        String size = req.getParameter("size");
        final int value;
        try {
            value = Integer.parseInt(size);
        } catch (NumberFormatException e) {
            resp.sendError(505, "Internal Error");
            return;
        }
        String arr[] = new String[value];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = req.getParameter("field" + i);
        }
        // ...
    }
}
